// 当前这个模块:api进行统一管理
import requests from "./ajax";
import mockRequests from "./mockAjax";

// 向服务器发起ajax请求 获取三级菜单的数据
export const reqCategoryList = () => requests.get(`/product/getBaseCategoryList`)

// 向模拟服务器发起ajax请求 banner图片数据
export const reqGetBannerList = () => mockRequests.get(`/banner`)

// 向模拟服务器发起ajax请求 floor底部图片数据
export const reqFloorList = () => mockRequests.get(`/floor`)

// 向服务器发起ajax请求 获取Search搜索页面的数据
export const reqGetSearchInfo = (params) => requests({ url: '/list', method: 'post', data: params })

// 向服务器发起ajax请求 获取detail详情页面的数据
export const reqGoodsInfo = (skuId) => requests({ url: `/item/${skuId}`, method: 'get' })

// 向服务器发起ajax请求 获取产品添加到购物车详情页面的数据
export const reqAddOrUpdateShopCart = (skuId, skuNum) => requests({ url: `/cart/addToCart/${skuId}/${skuNum}`, method: 'post' })

// /api/cart/cartList
// 向服务器发起ajax请求 获取购物车列表的数据
export const reqCartList = () => requests({ url: '/cart/cartList', method: 'get' })

// /api/cart/deleteCart/{skuId}
// 向服务器发起ajax请求 删除购物车列表的数据
export const reqDeleteCartById = (skuId) => requests({ url: `/cart/deleteCart/${skuId}`, method: 'delete' })

// /api/cart/checkCart/{skuId}/{isChecked}
// 向服务器发起ajax请求 修改商品选中状态
export const reqUpdateCheckedByid = (skuId, isChecked) => requests({ url: `/cart/checkCart/${skuId}/${isChecked}`, method: 'get' })

// /api/user/passport/sendCode/{phone}
// 获取验证码
export const reqGetcode = (phone) => requests({ url: `/user/passport/sendCode/${phone}`, method: 'get' })

// /api/user/passport/register
// 注册的api
export const reqUserRegister = (data) => requests({ url: `/user/passport/register`, data, method: 'post' })

// /api/user/passport/login
// 登录的接口
export const reqUserLogin = (data) => requests({ url: `/user/passport/login`, data, method: 'post' })

// /user/passport/auth/getUserInfo
// 登录完成之后 使用token向服务器要用户信息
export const reqUserInfo = () => requests({ url: `/user/passport/auth/getUserInfo`, method: "get" })

// 退出登录 /api/user/passport/logout
export const reqLogout = () => requests({ url: 'user/passport/logout', method: 'get' })

// 获取用户的地址信息 /api/user/userAddress/auth/findUserAddressList
export const reqAddressInfo = () => requests({ url: `user/userAddress/auth/findUserAddressList`, method: 'get' })

//获取商品清单  /api/order/auth/trade
export const reqOrderInfo = () => requests({ url: `order/auth/trade`, method: 'get' })

//提交订单api /api/order/auth/submitOrder?tradeNo={tradeNo}
export const reqSubmitOrder = (tradeNo, data) => requests({ url: `order/auth/submitOrder?tradeNo=${tradeNo}`, data, method: 'post' })

// 获取支付信息 /api/payment/weixin/createNative/{orderId}
export const reqPayInfo = (orderId) => requests({ url: `payment/weixin/createNative/${orderId}`, method: 'get' })

// 支付订单状态 /api/payment/weixin/queryPayStatus/{orderId}
export const reqPayStatus = (orderId) => requests({ url: `payment/weixin/queryPayStatus/${orderId}`, method: "get" })

// 获取我的订单数据 /api/order/auth/{page}/{limit}
export const reqMyorderList = (page, limit) => requests({ url: `order/auth/${page}/${limit}`, method: 'get' })